import java.net.*;
import java.util.ArrayList;

public class ChatServer extends Thread
{
	private static Client client;
	private static ArrayList<Client> clientList;
	public static void main(String[] args)
	{
		try
		{
			clientList = new ArrayList<Client>();
			UserList userList = new UserList(clientList);
			ServerSocket server = new ServerSocket(4445, 0, InetAddress.getByName("localhost"));
			System.out.println("server is started");
			while (true)
			{
				Socket ss = server.accept();
				if (ss!=null)
				{
					System.out.println("connected");
					client = new Client(ss, userList);
					userList.registerUser(client);
					new Thread(client).start();
				}
				Thread.currentThread();
				Thread.sleep(1);
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("init error: " + e);
		}
	}
}







